-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concrete type parameters for types as type members #116
Conversation
Not applied to module-qualified types yet. This lets the following actually work: type opt 'a = Some 'a | None type int_opt = opt int Up until this commit any attempt to use `int_opt` would cause a unification failure because we weren't capturing `int` as an actual parameter and associated variable name. Now for each parameter that is a concrete type we synthesize a variable name for it.
Refering to module.type_name with concrete type parameters now works.
The exact same block to link concrete types to synthetic type variables occurred twice, now it's a single function.
Haven't had time for proper review yet, but this fails to compile for me with
Update: |
One thing I think causes more trouble than it helps us is that we use the same construct
Perhaps we should rather parse it as:
i.e. a type application takes some type arguments (in this case t_int). When seeing the type application, the typer then looks up You might end up with the same end result when you do as you do here, but it is more confusing (at least to me), to have @j14159: These are just opinions. You've got a +1 to merge if you think your approach makes more sense. |
Good catch on that example, thanks! I've added it as a test and will fix that, it looks like somehow we're trying to unify I think you make a good point with |
Unifying two different ADTs when one is a member of the other called unify/4 with the incorrect order of arguments.
Fixes #113
Lets us write:
and actually use
int_opt
. Prior to this fix usingint_opt
, e.g. likeIntOpt Some 1
would fail to type as it tried to unifyt_int
andundefined
. We weren't capturingint
as a value for a type variable.cc/ @danabr for review as we've discussed this fix prior.